Skip to content

Modernize Build System and CI/CD with uv and PEP Standards#123

Open
abstract-333 wants to merge 4 commits intoipinfo:masterfrom
abstract-333:feat/migrate-uv
Open

Modernize Build System and CI/CD with uv and PEP Standards#123
abstract-333 wants to merge 4 commits intoipinfo:masterfrom
abstract-333:feat/migrate-uv

Conversation

@abstract-333
Copy link

@abstract-333 abstract-333 commented Feb 28, 2026

Summary

Modernize packaging and CI/CD workflows by introducing a fully declarative, standards-compliant build system alongside the existing setup. By adopting pyproject.toml and uv, we improve reproducibility and performance in CI/CD while ensuring full backward compatibility for developers using legacy tools.

Proposed Changes

🛠 Build System Migration (PEP 621)

  • Dual Metadata Support: Introduced pyproject.toml as the primary source of truth for project metadata.
  • No File Deletions: Retained setup.py and requirements.txt to ensure that existing automated scripts or developers preferring standard pip workflows face zero interruptions.
  • Modern Backend: Integrated hatchling as the build backend, which works seamlessly with modern PEP standards while allowing legacy tools to fall back to the existing setup.
  • Deterministic Locking: Added uv.lock for 100% reproducible environments in CI, while maintaining requirements.txt for those not yet using uv.

🏷 Versioning & Compatibility (PEP 396)

  • Standardized Attribute: Introduced the industry-standard __version__ attribute in compliance with PEP 396.
  • Backward Compatible Aliasing: Retained SDK_VERSION as a deprecated alias to ensure any internal or external tools importing that specific constant do not break.
  • Import Syncing: Updated ipinfo/handler_utils.py to pull the version dynamically, ensuring pyproject.toml and the code remain in sync.

🚀 CI/CD Optimization (GitHub Actions)

  • Native uv Integration: Transitioned GitHub Actions to use astral-sh/setup-uv. This leverages global caching and significantly faster dependency resolution.
  • Optimized Sync: Switched from pip install to uv sync --all-groups in CI to ensure a perfectly mirrored test environment.
  • Speed Gains: Reduced total CI execution time by ~15 seconds per workflow run by eliminating redundant build-isolation steps.

🛡 Stability & Compatibility Guarantee

This PR follows a "Parallel Path" strategy to ensure a frictionless transition:

  1. For uv users: Use uv sync and uv run pytest for a lightning-fast, isolated experience.
  2. For pip users: Standard pip install -r requirements.txt continue to work exactly as they did before.

🧪 Testing Performed

  • Verified uv lock generates a valid lockfile.
  • Successfully ran uv build to generate .whl and .tar.gz distributions.
  • Ran uv run pytest (Pro API-dependent tests were not executed due to missing Pro API key).
  • Verified User-Agent headers correctly reflect the version string from __version__.

- Replace imperative setup.py with declarative pyproject.toml (PEP 621)
- Adopt PEP 517/518 compliant build system using hatchling
- Pin `requires-python = ">=3.10"` to align with Build CI defaults
- Remove pip-tools as uv natively handles locking and syncing
- Initialize uv.lock for deterministic and faster dependency resolution
- Reorganize dev dependencies into [dependency-groups]
- Update ipinfo/handler_utils.py to use __version__ instead of SDK_VERSION
- Remove legacy version imports in setup.py to follow PEP 517
- Ensure User-Agent strings reflect the standardized version attribute
- Align internal API with PEP 396 module versioning conventions
- Replace legacy `uv pip install` with `uv sync --all-groups` for locked dev environments
- Remove manual `requirements.txt` installation in favor of pyproject.toml discovery
- Clean up `uv build` by removing unnecessary `--no-build-isolation` flag
- Leverage `astral-sh/setup-uv` caching for faster test and publish runs
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant